package com.briup.recognition.web.controller;

import com.briup.recognition.bean.UserRole;
import com.briup.recognition.service.IUserRoleService;
import com.briup.recognition.utils.Message;
import com.briup.recognition.utils.MessageUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/UserRole")
public class UserRoleController {
    @Resource
    private IUserRoleService userRoleService;

    @GetMapping("query")
    public Message query(){
        List<UserRole> list = userRoleService.query();
        return MessageUtil.success(list);
    }
    @GetMapping("queryId")
    public Message queryId(Long id){
        UserRole userRole = userRoleService.queryId(id);
        return MessageUtil.success(userRole);
    }

    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(UserRole userRole){
        userRoleService.saveOrUpdate(userRole);
        return MessageUtil.success("操作成功");
    }

    @DeleteMapping("deleteById")
    public Message deleteById(long id){
        userRoleService.deleteById(id);
        return MessageUtil.success("删除成功");
    }
}
